package XZK010203AND002;

import java.util.Scanner;

/**
 * 猜拳游戏
 *
 * @author bing.z 2021/5/28 20:56
 **/
public class Demo {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Machine machine = new Machine();
        System.out.println("猜拳游戏开始~");
        System.out.println("请输入游戏轮次(n>0)：");
        int n = input.nextInt();
        // uScore: 玩家得分 mScore: 机器得分 total: 总分
        int uScore = 0, mScore = 0, total = 0;
        int uFist, machineFist;
        while (n-- > 0) {
            System.out.println("1.剪刀 2.石头 3.布");
            uFist = input.nextInt();
            machine.randomFist();
            machineFist = machine.getFistType();
            System.out.println("本轮机器人出 " + (machineFist == 1 ? "剪刀" : machineFist == 2 ? "石头" : "布"));
            System.out.println(machineFist + " , " + uFist);
            if ((uFist + 1) % 3 == machineFist % 3) {
                // loser
                mScore++;
                System.out.println("本轮你输了~");
            } else if ((machineFist + 1) % 3 == uFist % 3) {
                // winner
                uScore++;
                System.out.println("本轮你赢了~");
            } else if (machineFist == uFist) {
                // equal
                System.out.println("本轮平局~");
            }
            total++;
        }
        System.out.println("猜拳游戏结束~");
        System.out.println("共游戏 " + total + " 次，你赢了 " + uScore + " 次~");
        if (uScore > mScore) {
            System.out.println("恭喜你，获得最终胜利~");
        } else {
            System.out.println("很遗憾，没有战胜机器人，再接再厉~");
        }
    }
}
